#ifndef MEASUREFACADE_HPP
#define MEASUREFACADE_HPP

#include "EvalBleedThroughAdd.hpp"
#include "EvalBleedThroughIntensity2Back.hpp"
#include "EvalBleedThroughIntensity2Ink.hpp"
#include "EvalBleedThroughSubstitutionGrowing.hpp"
#include "EvalBleedThroughVersoQuantity.hpp"
#include "EvalBleedThroughSubstitution.hpp"
#include "MesureTemplateMethod.hpp"

#include <girlTools/girlToolsImage.hpp>
#include <girlTools/girlToolsPngCodec.hpp>

#include <map>
#include <vector>
#include <string>

#include <iostream>

using namespace std;

class MeasuresFacade
{

public :

        MeasuresFacade();

        ~MeasuresFacade()
        {
            for(int i = 0; i < selectedMeasures.size(); i++)
            {
                delete selectedMeasures[i];
            }
            selectedMeasures.clear();
        }

        MesureTemplateMethod * selectMeasure(std::string measureName)
        {
           bool trouve = false;
           int i = 0;

           while(!trouve && i < allMeasures.size())
           {
               if(allMeasures[i]->getName() == measureName)
               {
                   MesureTemplateMethod *method = allMeasures[i];
                   selectedMeasures.push_back(method);
                   trouve = true;
               }
               i++;
           }
           return (trouve ? allMeasures.at(i-1) : NULL);
        }


        void measure(const girl::tools::Image &image)
        {
            assertParamsAreOk();
            for(int i = 0; i < selectedMeasures.size(); i++)
            {
                cout << selectedMeasures[i]->evaluate(image) << endl;
            }
        }
	
	
	char * measure_sans_string(char* recto, char* verso)
	{
		return test();
	}
	char * test();
	
public :
        std::vector<MesureTemplateMethod *> allMeasures;
        std::vector<MesureTemplateMethod *> selectedMeasures;

protected :
        /**
          * \throws Exceptions::MessageException
          */
        bool assertParamsAreOk()
        {
            for(int i = 0; i < selectedMeasures.size(); i++)
            {
                if(! selectedMeasures[i]->parametersOk())
                {
                    std::string message("Parameters for");
                    message.append(selectedMeasures[i]->getName());
                    message.append("are not valid (image is null ?)");
                    throw Exceptions::MessageException(message);
                }
            }
        }

	
	
	
};


#endif


	
